﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using L = Science.Mathematics.LinearAlgebra;

namespace Strang3Ed.Chapter02.Section4
{
    public class Example04
    {
        public Example04()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
        public void Compute()
        {
            L.Matrix[,] a = new L.Matrix[1, 3];
            double[,] x0 = {{1.0},
                           {-3.0},
                           {-4.0}};
            a[0, 0] = new L.Matrix(x0);
            double[,] x1 = {{0.0},
                           {1.0},
                           {0.0}};
            a[0, 1] = new L.Matrix(x1);
            double[,] x2 = {{0.0},
                           {0.0},
                           {1.0}};
            a[0, 2] = new L.Matrix(x2);

            L.Matrix[,] b = new L.Matrix[3, 1];
            double[,] x4 = { { 1.0, 12.0, 13.0 } };
            b[0, 0] = new L.Matrix(x4);
            double[,] x5 = { { 3.0, 15.0, 8.0 } };
            b[1, 0] = new L.Matrix(x5);
            double[,] x6 = { { 4.0, 19.0, 18.0 } };
            b[2, 0] = new L.Matrix(x6);

            L.BlockMatrix A = new L.BlockMatrix(a);
            L.BlockMatrix B = new L.BlockMatrix(b);
            L.Matrix AB = A * B;

            result += AB[0, 0].ToString() + "    ";
            result += AB[0, 1].ToString() + "    ";
            result += AB[0, 2].ToString() + "\r\n";

            result += AB[1, 0].ToString() + "    ";
            result += AB[1, 1].ToString() + "    ";
            result += AB[1, 2].ToString() + "\r\n";

            result += AB[2, 0].ToString() + "    ";
            result += AB[2, 1].ToString() + "    ";
            result += AB[2, 2].ToString() + "\r\n";
        }
    }
}
/*
1    12    13
0    -21    -31
0    -29    -34
*/